package com.keyinong.park.popupadapter;

import java.util.ArrayList;

import com.keyinong.park.R;
import com.keyinong.park.homebean.ParkInfoBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ParkNameAdapter extends BaseAdapter {
	Context context;
	ArrayList<ParkInfoBean> list;

	public ParkNameAdapter(Context context, ArrayList<ParkInfoBean> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
          ViewHandle handle;
          if(view==null){
        	  handle=new ViewHandle();
        	  view=LayoutInflater.from(context).inflate(R.layout.item_popup_parkname, null);
        	  handle.tv_parkName=(TextView) view.findViewById(R.id.tv_parkName);
             view.setTag(handle);
          }else{
        	  handle=(ViewHandle) view.getTag();
          }
          handle.tv_parkName.setText(list.get(position).getParkname());
		return view;
	}

	private class ViewHandle {
		TextView tv_parkName;
	}

}
